Skip to content

Async successors #363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Nov 15, 2019
Merged

Async successors #363

merged 16 commits into from
Nov 15, 2019

Conversation

felipesere
Copy link
Contributor

This doesn't compile at the moment, but I felt it was easier to get pointers on code than hypotheticals in Discord.

The current compile error is:

error[E0599]: no method named `poll` found for type `Fut` in the current scope
  --> src/stream/stream/successor.rs:51:52
   |
51 |         match self.as_mut().successor()(self.next).poll(cx) {
   |                                                    ^^^^ method not found in `Fut`
   |
   = help: items from traits can only be used if the type parameter is bounded by the trait
help: the following trait defines an item `poll`, perhaps you need to restrict type parameter `Fut` with it:
   |
41 | impl <F, Fut: core::future::future::Future, T> Stream for Successor<F, Fut, T>
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

which confuses me because I thought I had that trait bound on the where?

@ghost
Copy link

ghost commented Oct 17, 2019

I think the error is saying you're calling .poll(cx) on a Fut whereas you should be calling it on a Pin<&mut Fut>, i.e. the future is not pinned.

We should store the future returned by successor(next) into the Successor struct and then poll it. Note that if polling returns Poll::Pending, later on we'll want to poll that same future again instead of asking successor(next) to give a fresh future.

@felipesere felipesere changed the title WIP: First attempt at successor Async successors Oct 18, 2019
@ghost ghost mentioned this pull request Oct 18, 2019
@felipesere
Copy link
Contributor Author

Anything I’d we would need to do to get this merged? 🤩

ghost
ghost previously requested changes Oct 20, 2019
@yoshuawuyts yoshuawuyts added the enhancement New feature or request label Oct 28, 2019
Copy link
Contributor

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great; thanks heaps!

@yoshuawuyts yoshuawuyts dismissed ghost ’s stale review November 15, 2019 17:04

changes implemented

@yoshuawuyts yoshuawuyts merged commit b5c3fb8 into async-rs:master Nov 15, 2019
@yoshuawuyts
Copy link
Contributor

Created a backup of the async impl here for future reference (e.g. when we get async closures): https://gist.github.com/yoshuawuyts/32fb44959c0bd66a683008ee1d540500. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants